﻿#include "SetScriptWaitDialog.h"

#include "QRegExpValidator"
#include "qmessagebox.h"

SetScriptWaitDialog::SetScriptWaitDialog(QWidget* parent):QDialog(parent)
{
  ui.setupUi(this);
  QRegExp regExp("^(\\d+)?$");
  ui.lineEdit_waitTime->setValidator(new QRegExpValidator(regExp, this));
  connect(ui.pushButton_confirm, &QPushButton::clicked, this, &SetScriptWaitDialog::accept);
  connect(ui.pushButton_cancel, &QPushButton::clicked,this,&SetScriptWaitDialog::reject);
  setFixedSize(size());
}
SetScriptWaitDialog::~SetScriptWaitDialog() {}
void SetScriptWaitDialog::accept()
{
  QString temp = ui.lineEdit_waitTime->text();
  if (temp.isEmpty()) {
      QMessageBox::information(this, QStringLiteral("消息"), QStringLiteral("等待时间不能为空"));
      return;
    }
  QDialog::accept();
}
int SetScriptWaitDialog::getWaitTime()
{
  return ui.lineEdit_waitTime->text().toInt()*1000;
}
